package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.domain.pojo.Log;
import com.itheima.domain.pojo.PageResult;
import com.itheima.domain.query.LogQueryParam;
import com.itheima.mapper.LogMapper;
import com.itheima.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: Sch
 * @Date: 2025/07/18 16:51
 * @Description:
 */
@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogMapper logMapper;
    @Override
    public PageResult page(LogQueryParam logQueryParam) {
       //1.设置分页参数
        PageHelper.startPage(logQueryParam.getPage(), logQueryParam.getPageSize());
        //2.执行查询
        List<Log> logList = logMapper.findLogs(logQueryParam);
        //3.封装分页结果
        Page<Log> p = (Page<Log>) logList;
        return new PageResult(p.getTotal(), p.getResult());
    }
}
